package cn.itsource.basic.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author CTL
 * @Description 异步请求工具类
 * @date Created in 2023-05-16 14:27
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {
    private String code;//状态码，给 运维/开发 看的
    private Boolean success;//状态，失败与成功
    private String message;//信息,给 用户 看的
    private Object data;//数据

    //成功无数据
    public static AjaxResult createSuccess(){
        return new AjaxResult("0000",true,"操作成功",null);
    }
    //成功有数据
    public static AjaxResult createSuccess(Object obj){
        return new AjaxResult("0000",true,"操作成功",obj);
    }
    //失败无状态码
    public static AjaxResult createError(String msg){
        return new AjaxResult("1001",false,msg,null);
    }
    //失败有状态码
    public static AjaxResult createError(String code,String msg){
        return new AjaxResult(code,false,msg,null);
    }
}
